﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace NeuroIris
{
    /// <summary>
    /// Interaction logic for Node.xaml
    /// </summary>
    public partial class IrisNode : UserControl
    {
        public IrisNode()
        {
            W = new float[4];
            Sim = 0;
            InitializeComponent();
        }

        /// <summary>
        /// Neuron Weight
        /// </summary>
        public float[] W { get; set; }

        public float SepalLength { get; set; }

        public float SepalWidth { get; set; }

        public float PetalLength { get; set; }

        public float PetalWidth { get; set; }

        public float Hit { get; set; }

        public IrisEnum IrisType { get; set; }

        /// <summary>
        /// Last Similarity Value
        /// </summary>
        public float Sim { get; private set; }

        public void SetColor(Brush brush)
        {
            myNode.Fill = brush;
        }

        /// <summary>
        /// Liczba trafień gatunku do neuronu w trakcie nauczania
        /// </summary>
        public int SetosaCount { get; set; }

        /// <summary>
        /// Liczba trafień gatunku do neuronu w trakcie nauczania
        /// </summary>
        public int VersicolorCount { get; set; }

        /// <summary>
        /// Liczba trafień gatunku do neuronu w trakcie nauczania
        /// </summary>
        public int VirginicaCount { get; set; }


        public float Similarity(float[] x)
        {
            float Sim = 0;

            Sim += (x[0] - W[0]) * (x[0] - W[0]);
            Sim += (x[1] - W[1]) * (x[1] - W[1]);
            Sim += (x[2] - W[2]) * (x[2] - W[2]);
            Sim += (x[3] - W[3]) * (x[3] - W[3]);

            return Sim;
        }

        public void SetWinner(bool t) 
        {
            if (t)
            {
                myNode.StrokeThickness = 4;
            }
            else
            {
                myNode.StrokeThickness = 1;
            }
        }

    }
}
